package com.javasm.service.MisMannageService.impl;


import com.javasm.dao.MisMannageDao.ShowDao;
import com.javasm.dao.MisMannageDao.impl.ShowDaoImpl;
import com.javasm.entity.MisMannageEntity.ProdInfo;
import com.javasm.entity.MisMannageEntity.TbShow;
import com.javasm.service.MisMannageService.ShowService;

import java.util.List;

public class ShowServiceImpl implements ShowService {

    @Override
    public List<TbShow> getrec(Integer id) {
        ShowDao showDao = new ShowDaoImpl();
        TbShow tbShow = showDao.getrec(id);
        //  System.out.println(tbShow);
        String relevancyIds = tbShow.getRelevancyIds();
        List<TbShow> tbShows = showDao.getProdName(relevancyIds);
        return tbShows;
    }

    @Override
    public Integer editSubs(String ids, Integer id) {
        ShowDao showDao = new ShowDaoImpl();
//        String[] split = ids.split(",");
//        List<Integer> integers = new LinkedList<>();
//        for (String s : split) {
//            integers.add(Integer.parseInt(s));
//        }
        //System.out.println(ids);
//        List<Integer> subIds = showDao.queSubs(ids);
//        String s = ids.toString();
//        String substring = s.substring(1, s.lastIndexOf("]"));
//        System.out.println(substring + "454556");
        Integer index = showDao.editSubs(ids, id);

        return index;
    }

    @Override
    public List<TbShow> getAllShow() {
        ShowDao showDao = new ShowDaoImpl();
        List<TbShow> showById = showDao.getShow();

        return showById;
    }

    @Override
    public Integer editshow(TbShow tbShow) {
        ShowDao showDao = new ShowDaoImpl();
        Integer editshow = showDao.editshow(tbShow);
        return editshow;
    }

    @Override
    public Integer addshow(TbShow tbShow) {
        ShowDao showDao = new ShowDaoImpl();
        Integer addshow = showDao.addshow(tbShow);
        return addshow;
    }

    @Override
    public List<ProdInfo> getProdName() {
        ShowDao showDao = new ShowDaoImpl();
        List<ProdInfo> prodName = showDao.getProdName();
        return prodName;
    }

    @Override
    public Integer getTotalnum(String prodName) {
        ShowDao showDao = new ShowDaoImpl();
        Integer totalnum = showDao.getTotalnum(prodName);
        return totalnum;
    }

    @Override
    public List<TbShow> getShow(Integer page, Integer pageSize, String prodName) {
        ShowDao showDao = new ShowDaoImpl();
        List<TbShow> showById = showDao.getShowById(page, pageSize, prodName);
        return showById;
    }
}
